Quickfort remaining features#185
Conversation
the mesh of interdependent feature branches has become too complicated
to merge individually, so here's a combined merge for the final
milestones for the first public release of DFHack quickfort. Changes
include:
Major features
--------------
- implement GUI interface for quickfort. can do everything except set
settings. remembers last filter and selected position and restores
them when GUI is reinvoked.
- allow multiple blueprints in a single .csv file or spreadsheet sheet.
a new blueprint begins when a modeline is detected in the first
column.
- new blueprint mode: zone. Like place mode but for zones. currently
can't initialize zone settings (like pit vs pond). will address this
later. tricky bit of this mode was ensuring a zone is not selected
when it is deleted, since this causes a crash.
- new blueprint mode: meta. can run a series of related blueprints as if
they were one. can also change z-levels and then run a specified
blueprint.
- place and zone mode now recognize multi-type stockpiles and zones.
- implement new markers for modelines: hidden(), which hides the
blueprint from list output unless the --hidden parameter is specified,
and label(), which give the blueprint a name. both are primarily
useful when writing meta blueprints. you can hide blueprints that are
managed by a higher-level meta blueprint, and you need to give your
blueprints labels so the meta blueprint can refer to them. also
implemented message(), which displays a message to the player after
the blueprint has been applied. these markers can be defined in any
order.
Bugfixes and minor changes
--------------------------
- remove the '+' alias for shift. it's too useful of a key to map to
something else. also, it seems that the original quickfort only mapped
+ to shift when it is followed by {Enter}, which is a special case
that we don't really want to support. {Shift}{Enter} already has the
'@' shortcut.
- refactor screw pump database entries into a generator function
- initialize furnaces can accept workshop orders (we correctly
initialized real workshops, but furnaces got missed)
- create quickfort setting 'buildings_use_blocks', which restricts
anything that requires a generic building material to instead require
a block
- refactor extent overwriting into a separate function to centralize
memory leak protection
- only output one set of stats per quickfort command invocation instead
of one set per (blueprint, zlevel) tuple.
- move some parsing logic from list.lua to parse.lua to centralize it
- split do_command() into a frontend and backend so meta blueprints can
call the backend function directly
- refactored the list command into a frontend and backend so the gui can
call the backend function directly
- handle multi-line quoted strings in .csv files
lethosor
left a comment
There was a problem hiding this comment.
I tested out build mode a bit - the orders/planning/undo support are pretty awesome. Incidentally, this didn't work when I was testing just #182, but it appears that whatever issues were present there are now resolved.
#build
b,,
,b,
,,b
I do have a couple questions:
- Blueprints in
blueprints/libraryseem to no longer be listed byquickfort list- is this intentional? - Moving
dreamfort.csvintoblueprintsgives a bunch of entries like this - is the-n "nil"intentional?
30) "dreamfort.csv" -n "nil" (query: configure rooms); cursor start: staircase center
31) "dreamfort.csv" -n "nil" (dig: ); cursor start: staircase center
32) "dreamfort.csv" -n "nil" (meta: build workshops and stockpiles, configure stockpiles); cursor start: staircase center
36) "dreamfort.csv" -n "nil" (dig: ); cursor start: staircase center
37) "dreamfort.csv" -n "nil" (meta: furniture, stockpiles, hospital, garbage dump); cursor start: staircase center
internal/quickfort/orders.lua
Outdated
| function enqueue_orders(stats, buildings, building_db, ctx) | ||
| local order_specs = ctx.order_specs or {} | ||
| ctx.order_specs = order_specs | ||
| local reactions = stockflow.reaction_list -- don't cache this; it can reset |
There was a problem hiding this comment.
It looks like this is uninitialized until stockflow's initialize_world() is called, which doesn't happen if the plugin is disabled (I didn't check what happens if it's enabled). I'm not entirely sure if you require stockflow to be enabled, but the current behavior just produces an "unhandled label" error when reaction_list is empty, which I don't think is intentional.
Edit: I guess you could just use reactions = stockflow.collect_reactions() here, actually, to avoid messing with stockflow's internal data (initialize_world() calls clear_cache(), and I don't know if that has unintended side effects)
There was a problem hiding this comment.
that's not a bad idea. no refactoring needed, and no need for the plugin to be enabled -- though can I access the stockflow lua module if the plugin isn't enabled? I'll play with this a bit. At least I can output a proper error message if I need stockflow and it isn't available.
|
I'm not quite sure why GitHub thinks there are merge conflicts - maybe because of the other merged PRs? I was able to merge this branch into |
intentional. I didn't want library files cluttering up the list output. players will usually want to just see their own blueprints. pass
very unintentional. and unexpected. I've been testing this extensively while developing the gui. I may have a bad merge somewhere. I'll look into this. Edit: fixed |
merged locally, and no conflicts that I could see. |
ensure marker data is nil when the string is 0-length fix typo referring to non-existent variable
lethosor
left a comment
There was a problem hiding this comment.
Looks good!
The only thing I'd change in the GUI is the colors - you're using COLOR_DARKGREY for labels, which is usually used for disabled labels (I'll change it to COLOR_GREY)
|
I see now that you were imitating the built-in shift+enter control in ListBox - I changed that too. I also took advantage of the |
DFHack/dfhack#499
the mesh of interdependent feature branches has become too complicated to merge individually, so here's a combined merge for the final milestones for the first public release of DFHack quickfort. Marked WIP until the other PRs (which this PR builds on) are merged. Changes
include:
Major features
implement GUI interface for quickfort. can do everything except set settings. remembers last filter and selected position and restores them when GUI is reinvoked.
allow multiple blueprints in a single .csv file or spreadsheet sheet. a new blueprint begins when a modeline is detected in the first column.
new blueprint mode: zone. Like place mode but for zones. currently can't initialize zone settings (like pit vs pond). will address this later. tricky bit of this mode was ensuring a zone is not selected when it is deleted, since this causes a crash.
new blueprint mode: meta. can run a series of related blueprints as if they were one. can also change z-levels and then run a specified blueprint.
place and zone mode now recognize multi-type stockpiles and zones.
implement new markers for modelines: hidden(), which hides the blueprint from list output unless the --hidden parameter is specified, and label(), which give the blueprint a name. both are primarily useful when writing meta blueprints. you can hide blueprints that are managed by a higher-level meta blueprint, and you need to give your blueprints labels so the meta blueprint can refer to them. also implemented message(), which displays a message to the player after the blueprint has been applied. these markers can be defined in anyhorder.
Bugfixes and minor changes
remove the '+' alias for shift. it's too useful of a key to map to something else. also, it seems that the original quickfort only mapped + to shift when it is followed by {Enter}, which is a special case that we don't really want to support. {Shift}{Enter} already has the '@' shortcut.
refactor screw pump database entries into a generator function
initialize furnaces can accept workshop orders (we correctly initialized real workshops, but furnaces got missed)
create quickfort setting 'buildings_use_blocks', which restricts anything that requires a generic building material to instead require a block
refactor extent overwriting into a separate function to centralize memory leak protection
only output one set of stats per quickfort command invocation instead of one set per (blueprint, zlevel) tuple.
move some parsing logic from list.lua to parse.lua to centralize it
split do_command() into a frontend and backend so meta blueprints can call the backend function directly
refactored the list command into a frontend and backend so the gui can call the backend function directly
handle multi-line quoted strings in .csv files